"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {};
// 类装饰器
// 🚀 更类型安全的写法     你甚至可以返回一个扩展后的类
function Logger(constructor) {
    var _a;
    constructor.ttype = "我是类装饰器";
    // 这是一个新类，它继承了原始类，但它本身有自己的 prototype，被下面的覆盖了
    constructor.prototype.user = function () {
        console.log("我是zks");
    };
    console.log("类的名称为", constructor.name);
    return _a = class extends constructor {
            constructor(...args) {
                super(args);
            }
            student() {
                console.log("这是一个实例方法");
            }
        },
        _a.type = 'Entity',
        _a;
}
// function Logger(constructor: Function) {
//     console.log("类的名称为", (constructor as any).name)
//     ///这个constructor是一个构造函数相当于就是Person你可以在上面挂载静态属性和实例方法
//     constructor.prototype.zks = function () {
//         console.log("这是一个实例方法")
//     };
//     (constructor as any).type = 'Entity';
// }
let Person = class Person {
    constructor() {
        console.log('A');
    }
};
Person = __decorate([
    Logger,
    __metadata("design:paramtypes", [])
], Person);
const p = new Person();
console.log(p);
// 工厂函数 借助函数返回类装饰器  可以进行ts提示
function TestDe(flag) {
    return function (constructor) {
        if (flag) {
            return class extends constructor {
                constructor() {
                    super(...arguments);
                    this.name = "zks";
                    this.age = 18;
                }
                show() {
                    console.log(this.name);
                }
            };
        }
        else {
            return class extends constructor {
                unreachable() {
                    console.log("这是不可访问的");
                }
            };
        }
    };
}
const TestPerson = TestDe(true)(class Person {
    constructor(uname) {
        this.uname = "再找找看是";
        this.uname = uname;
    }
});
const testP = new TestPerson("江苏无锡");
console.log(testP); //class_2 { uname: '江苏无锡', name: 'zks', age: 18 }
